Skip to content

Propagate request handler agent metadata#1949

Merged
stephentoub merged 3 commits into
mainfrom
stephentoub-propagate-callback-fields
Jul 10, 2026
Merged

Propagate request handler agent metadata#1949
stephentoub merged 3 commits into
mainfrom
stephentoub-propagate-callback-fields

Conversation

@stephentoub

Copy link
Copy Markdown
Collaborator

The runtime now sends agent metadata on LLM inference request-start frames, but the SDKs also have hand-written request-handler adapters that were only exposing older fields like the session id. This threads the new metadata through those public callback contexts so consumers can identify the active agent, parent agent, and interaction type across SDKs.

Summary

  • Propagate agentId, parentAgentId, and interactionType from llmInference.httpRequestStart into request-handler contexts for Node, Python, Go, .NET, Rust, and Java.
  • Extend CAPI/BYOK request-handler E2Es to assert root-agent metadata is visible.
  • Extend subagent E2Es, and add Java subagent coverage, to assert subagent inference requests carry a distinct parentAgentId.
  • Fix .NET request-handler forwarding so GET/HEAD requests do not get an empty content body while forwarding headers.

Validation

  • Node targeted E2Es for request-handler session metadata and subagent hooks passed.
  • Python targeted E2Es for request-handler session metadata and subagent hooks passed.
  • Go targeted E2Es for request-handler session metadata and subagent hooks passed.
  • .NET targeted E2Es for request-handler session metadata and subagent hooks passed on net8.0 and net472.
  • Java targeted Maven verify for request-handler session metadata and subagent hooks passed.
  • Formatting and whitespace checks passed; Rust test compilation remains locally blocked by missing clang required by ring before SDK tests compile.

Generated by Copilot

Copilot AI review requested due to automatic review settings July 8, 2026 16:50
@stephentoub stephentoub requested a review from a team as a code owner July 8, 2026 16:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR propagates agent metadata (agentId, parentAgentId, interactionType) from runtime llmInference.httpRequestStart frames into the public request-handler callback context across all SDKs, and extends E2E coverage (including new Java subagent coverage) to assert that metadata is visible—especially for subagent inference where parentAgentId should differ from agentId.

Changes:

  • Thread agentId, parentAgentId, and interactionType into request-handler contexts in Node, Python, Go, .NET, Rust, and Java adapters.
  • Extend request-handler E2Es (CAPI/BYOK) to assert root-agent metadata is populated on inference requests.
  • Extend subagent E2Es (and add Java subagent coverage) to assert subagent inference requests include a distinct parentAgentId.
Show a summary per file
File Description
rust/tests/e2e/subagent_hooks.rs Adds request-handler recording and asserts subagent inference carries parent/child agent metadata.
rust/tests/e2e/copilot_request_handler.rs Extends intercepted request records and assertions to include agent metadata on inference requests.
rust/src/copilot_request_handler.rs Adds agent metadata fields to CopilotRequestContext and wires them from httpRequestStart.
python/e2e/test_subagent_hooks_e2e.py Records request context metadata and asserts subagent inference includes parent_agent_id.
python/e2e/test_copilot_request_session_id_e2e.py Extends request interception records to include agent metadata and asserts presence.
python/copilot/copilot_request_handler.py Threads agent metadata from exchange into CopilotRequestContext.
nodejs/test/e2e/subagent_hooks.e2e.test.ts Adds request-handler recording and asserts subagent inference metadata is present/distinct.
nodejs/test/e2e/copilot_request_session_id.e2e.test.ts Extends intercepted request records to include agent metadata and asserts presence.
nodejs/src/copilotRequestHandler.ts Extends CopilotRequestContext and exchange context wiring for agent metadata.
java/src/test/java/com/github/copilot/SubagentHooksE2ETest.java New Java E2E validating subagent hooks and request-handler agent metadata.
java/src/test/java/com/github/copilot/CopilotRequestTestSupport.java Extends intercepted-request test record to include agent metadata.
java/src/test/java/com/github/copilot/CopilotRequestSessionIdE2ETest.java Adds assertions that inference requests include agent metadata.
java/src/main/java/com/github/copilot/LlmInferenceAdapter.java Parses agent metadata fields from request-start params and populates request context.
java/src/main/java/com/github/copilot/CopilotRequestContext.java Adds agent metadata fields + getters; ensures withUrl/withHeaders preserve them.
go/internal/e2e/subagent_hooks_e2e_test.go Adds RoundTripper-based recording and assertions for subagent inference agent metadata.
go/internal/e2e/copilot_request_session_id_e2e_test.go Extends intercepted request records and asserts agent metadata on inference requests.
go/copilot_request_handler.go Extends CopilotRequestContext with agent metadata and wires from HttpRequestStart.
dotnet/test/E2E/SubagentHooksE2ETests.cs Records request contexts and asserts subagent inference includes distinct parent/child agent ids.
dotnet/test/E2E/CopilotRequestSessionIdE2ETests.cs Adds assertions that intercepted inference requests include agent metadata.
dotnet/test/E2E/CopilotRequestE2EProvider.cs Extends intercepted request record shape to include agent metadata.
dotnet/src/CopilotRequestHandler.cs Adds agent metadata to CopilotRequestContext and fixes header forwarding logic for GET/HEAD.

Review details

  • Files reviewed: 21/21 changed files
  • Comments generated: 0
  • Review effort level: Low

@github-actions

This comment has been minimized.

Thread agentId, parentAgentId, and interactionType from llmInference request-start frames into the public request handler contexts across SDK languages.

Extend CAPI/BYOK and subagent request-handler tests to prove the metadata is observable, and fix .NET forwarding so GET/HEAD requests do not get an empty content body when forwarding headers.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@stephentoub stephentoub force-pushed the stephentoub-propagate-callback-fields branch from 39cb52f to 10ceaff Compare July 8, 2026 22:24
@github-actions

This comment has been minimized.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR propagates agentId/parentAgentId/interactionType to the request-handler context across all six SDK implementations. The changes are consistent in both coverage and API design:

SDK Fields Naming Convention
Node.js agentId, parentAgentId, interactionType camelCase ✅
Python agent_id, parent_agent_id, interaction_type snake_case ✅
Go AgentID, ParentAgentID, InteractionType PascalCase exported ✅
.NET AgentId, ParentAgentId, InteractionType PascalCase ✅
Java agentId(), parentAgentId(), interactionType() camelCase getters ✅
Rust agent_id, parent_agent_id, interaction_type snake_case ✅

Each language follows its own idiomatic conventions and all SDKs receive equivalent E2E test coverage asserting that root-agent and subagent inference requests carry the new metadata fields. No consistency issues found.

Generated by SDK Consistency Review Agent for issue #1949 · sonnet46 875.7K ·

@stephentoub stephentoub merged commit 46feb75 into main Jul 10, 2026
46 checks passed
@stephentoub stephentoub deleted the stephentoub-propagate-callback-fields branch July 10, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants